<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="${bpmTaskFrom.fromName}--${config.getKey('COMPANY_NAME')}" libs=["table"]/>
<link rel="stylesheet" href="${ctxStatic}/static/css/figol.css?V=${config.getDvVersion()}"/>

<div class="oa-form">
    <div class="form-top" style="margin-top:8px;padding-left:20px;">
        <button name="btn-pre-save" disabled class="btn btn-info btn-rounded btn-sm">
            <i class="fa fa-save" style="padding-right:5px;"></i>保存待发
        </button>
        <button disabled class="btn btn-info btn-rounded btn-sm">
            <i class="fa fa-plus-square" style="padding-right:5px;"></i>调用模板
        </button>
        <button disabled class="btn btn-info btn-rounded btn-sm">
            <i class="fa fa-save" style="padding-right:5px;"></i>存为模板
        </button>
        <button onclick="doPrint()" class="btn btn-info btn-rounded btn-sm">
            <i class="fa fa-print" style="padding-right:5px;"></i>打印
        </button>
    </div>
    <div class="form-bottom">
        <div class="form-bottom-left">
            <@f.form name="bidagency" class="form-horizontal">
            <div class="form-content">
                <div class="form-title">

                    <table style="width:100%;" class="table table-no-bordered table-form-title">
                        <tr>
                            <td width="10%" rowspan="2" style="text-align:center;border-bottom:0 !important;">
                                <button type="button" onclick="submitHandler()" style="padding:20px 30px;" class="btn btn-danger btn-rounded btn-sm">修 改</button>
                            </td>
                            <td width="6%" style="text-align:right;border-bottom:0 !important;">标题：</td>
                            <td style="border-bottom:0 !important;">
                                <@f.input readonly=true name="title" value="${bpmForm.title}" placeholder="${bpmForm.title}" required=true/>
                            </td>
                            <td width="15%" style="border-bottom:0 !important;">
                                <@f.select required=true name="priority" dictType="sys_bpm_priority" blankValue="${bpmForm.priority}" blankLabel="${dict.getLabel('sys_bpm_priority', bpmForm.priority)}"/>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align:right;border-bottom:0 !important;">流程：</td>
                            <td style="border-bottom:0 !important;">
                                <@f.input value="${proDef.name}" readonly=true name="bmp_name" placeholder="审批流程名称"/>
                            </td>
                            <td style="border-bottom:0 !important;">
                                <button type="button" onclick="preview('${bpmForm.processInstanceId}')" style="width:100%;" class="btn btn-info btn-rounded btn-sm">查看流程</button>
                            </td>
                        </tr>
                    </table>

                </div>
                <div id="printBox" class="form-main" style="padding-bottom:60px;background-color:#fff;overflow-x:hidden;overflow-y: auto;">

                    <#include "formToEdit.html"/>
                    <input type="hidden" name="id" value="${bpmForm.id}" />
                    <input type="hidden" name="modelKey" value="${bpmTaskFrom.modelKey}" />
                    <input type="hidden" name="formName" value="${bpmTaskFrom.fromName}" />
                </div>
            </div>
            <div class="form-attach">
                <div style="width:90%;margin:-1px auto 0;background-color:#ccc;">
                    <div class="button-attach" style="height:50px;line-height:50px;font-size:14px;background-color:#ccc;">
                        <i style="padding:0 5px 0 10px;" class="icon-attach fa fa-angle-double-down"></i>附言
                    </div>
                    <div style="width:99%;margin:0 auto;">
                        <textarea name="attachmentText" placeholder="2000字以内" style="border:1px solid #ddd;width:100%;height:70px;">${bpmForm.attachmentText}</textarea>
                    </div>
                </div>
            </div>
        </@f.form>
    </div>
    <div class="form-bottom-right" style="background-color: white;">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">相关数据</li>
                <li>流程预测</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">暂无相关数据</div>
                <div class="layui-tab-item">暂无流程预测</div>
            </div>
        </div>
    </div>
</div>
</div>


<@footer>
<script>jQuery.browser={};(function(){jQuery.browser.msie=false;jQuery.browser.version=0;if(navigator.userAgent.match(/MSIE ([0-9]+)./)){jQuery.browser.msie=true;jQuery.browser.version=RegExp.$1;}})();</script>
<script src="${ctxStatic}/static/js/jquery.jqprint.js"></script>
<script type="text/javascript">
    var prefix = baseURL + "bpm/bidagency";
    function doPrint(){
        $("#printBox").jqprint();
    }
    $('form[name=bidagency]').validate({
        rules:{
            project_name:{
                required:true,
                minlength: 1,
                maxlength: 200
            },
        },
        focusCleanup: true
    });

    function submitHandler() {
        if (opt.validate.form()) {
            console.log(prefix)
            opt.operate.save(prefix + "/edit", $('form[name=bidagency]').serialize());
        }
    }

    /*预览*/
    function preview(processInstanceId) {
        var options = {
            url: baseURL + "bpm/processInstance/preview/" + processInstanceId,
            title: '<i class="fa icon-loop"></i> <@ctx.i18n text = "流程跟踪"/>',
            btn:['<i class="fa fa-close"></i> '+$.i18n.prop("取消")],
            width: $(top.window).width() - 300,
            height: $(top.window).height() - 200
        };
        opt.modal.openMainWin(options);
    }

    /*$("button[name=btn-save]").click(function () {
        console.log("aaaaaaaaaaaa")
        if (opt.validate.form()) {
            console.log("bbbbbbbbbbbbbbbbb")
            opt.operate.post(prefix + "/add", $('form[name=bidagency]').serialize());
        }
    });*/

    $(".button-attach").click(function () {
        $(".form-attach").toggleClass("expand");
        $(".icon-attach").toggleClass("fa-angle-double-up").toggleClass("fa-angle-double-down");
    });

    layui.use('element', function(){
        var element = layui.element;

        //…
    });
</script>
</@footer>
</@pageTheme>